package cn.edu.ctgu.junitTest;


public class Commission {
    public String com(String[][] in) {
        Double sales;
        Integer[] total = new Integer[]{0, 0, 0};
        for (String[] i : in) {
            if (!"-1个枪机售出".equals(i[0]))
                for (int j = 0; j < i.length; j++)
                    total[j] += Integer.parseInt(i[j]);
        }
        sales = cal(total);//计算佣金
        if (!sales.equals(new Double(0)))
            return sales.toString();

        return null;
    }

    double cal(Integer[] integers) {
        if (search(integers)) {
            System.out.println("超出厂商限制！");
        }
        double sum, ans = 0;
        sum = 45 * integers[0] + 30 * integers[1] + 25 * integers[2];//计算总额
        if (sum <= 1000) {
            ans = sum * 0.1;
        } else if (sum > 1000 && sum <= 1800) {
            ans = 100 + (sum - 1000) * 0.15;
        } else if (sum > 1800) {
            ans = 190 + (sum - 1800) * 0.2;
        }
        return ans;
    }

    Boolean search(Integer[] integers) {
        if (integers[0] >= 1 && integers[0] <= 70 && integers[1] >= 1 && integers[1] <= 80 && integers[2] >= 1 && integers[2] <= 90) {
            return false;
        }
        return true;
    }
}